/**
 * @author phi
 */

var window = window || {};

window.onload = function()
{
    
    $id("submit").addEventListener("click", function()
    {
        var text = $id("target").value;
        var pattern;
        var replace;
        
        for (var i=0; i<5; ++i) {
            pattern = $class("pattern", i).value;
            replace = $class("replace", i).value;
            text = text.replace(new RegExp(pattern, 'gm'), replace);
        }
        
        $id("result").value = text;
    });
    
};
